import axios from "axios"
import Vue from "vue"

axios.defaults.baseURL = "/api"
Vue.prototype.$static_url ='http://127.0.0.1:3000'
axios.interceptors.request.use(
    function(request){
        const storage = JSON.parse(localStorage.getItem("loginData"||'{}'))
        if(storage){
            request.headers.Authorization = storage.token
        }
        return request
    }
)

axios.interceptors.response.use(
    function(response){
        //响应如果遇到token过期，要求从新登录 403
        return response.data // 根据axios接口惯例，过滤多余的内容
    }
)
export default axios